package com.ben.chatroom.session.entity;

import lombok.Getter;
import lombok.Setter;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 用户缓存
 *
 * @author hungyijun
 */
public class UserCache {

    @Getter
    @Setter
    private String userId;

    @Getter
    private Map<String, SessionCache> map = new LinkedHashMap<>();


    public UserCache(String userId) {
        this.userId = userId;
    }

    public void addSession(SessionCache cache) {
        map.put(cache.getSessionId(), cache);
    }

    public void removeSession(String sessionId) {
        if (map.containsKey(sessionId)) {
            map.remove(sessionId);
        }
    }


}